package com.example.hf_v1.controller;

import com.example.hf_v1.config.Result;
import com.example.hf_v1.entity.DiyLikes;
import com.example.hf_v1.service.DiyLikesService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/diyLikes")
public class DiyLikesController {
    @Resource
    private DiyLikesService diyLikesService;

    //增加个人爱好
    @RequestMapping("/addDiyLikes")
    public Result addDiyLikes(@RequestBody DiyLikes diyLikes) {
        return Result.success(diyLikesService.save(diyLikes));
    }

    //删除个人爱好
    @RequestMapping("/deleteDiyLikes")
    public Result deleteDiyLikes(Integer diyId){
        return Result.success(diyLikesService.removeById(diyId));
    }

    //修改个人爱好
    @RequestMapping("/updateDiyLikes")
    public Result updateDiyLikes(@RequestBody DiyLikes diyLikes){
        return Result.success(diyLikesService.updateById(diyLikes));
    }

    //查询所有个人爱好
    @RequestMapping("/selectAllDiyLikes")
    public Result selectAllDiyLikes(){
        return Result.success(diyLikesService.list());

    }
}
